<script setup lang="ts">
import { RouterView } from 'vue-router'
import { useDirection } from '@/hooks/useDirection'
const direction = useDirection()
</script>

<template>
  <router-view v-slot="{ Component }">
    <Transition :name="direction" :css="!!direction">
      <KeepAlive :include="'HomeView'">
        <component :is="Component" />
      </KeepAlive>
    </Transition>
  </router-view>
</template>

<style scoped>
.page-out-enter-active,
.page-out-leave-active,
.page-in-enter-active,
.page-in-leave-active {
  will-change: transform;
  transition: transform 0.25s ease-out;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  position: fixed;
  backface-visibility: hidden;
  perspective: 1000;
  /* 一般应用为项目中的背景色 */
  background-color: #ffffff;
}

.page-out-enter-from {
  transform: translateX(-30%);
}

.page-out-leave-active {
  transform: translateX(100%);
  z-index: 2;
}

.page-in-enter-from {
  transform: translateX(100%);
}

.page-in-leave-active {
  transform: translateX(-30%);
}
</style>
